<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .divForm{
            position: absolute;/*绝对定位*/
            width: 300px;
            height: 200px;

            border: 1px solid red;
            text-align: center;/*(让div中的内容居中)*/
            top: 50%;
            left: 50%;
            margin-top: -200px;
            margin-left: -150px;
        }
    </style>
</head>
<body>
<div class="divForm">
<form action="" method="post">

    <div class="form-group">
        <label for ="username">账号</label>
        <input type ="text" class="form-control" id="username">
    </div>

    <div class="form-group">
        <label for ="password">密码</label>
        <input type ="password" class="form-control" id="password">
    </div>
    <button type ="button" class="btn btn-primary">登录</button>
</form>
    </div>

</body>
</html>